package com.itheima.utils;

import com.itheima.domain.system.SysLog;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;

public class LogUtil {

    private LogUtil(){

    }

    public static void logMethodForFilter(HttpServletRequest request){
        String requestURI = request.getRequestURI();
        String operation = request.getParameter("operation");
        String remoteAddr = request.getRemoteAddr();

        SysLog sysLog = new SysLog();

        sysLog.setVisitTime(new Date());
        sysLog.setUsername("admin");
        sysLog.setIp("127.0.0.1");
        sysLog.setUrl(requestURI);
        sysLog.setMethod(operation);

        request.setAttribute("log",sysLog);

        System.out.println("过滤器:"+sysLog);
    }


}
